<% content_for :title do %>Producten<% end %>
<p><%=link_to('Voeg een product toe', url_for(:action => 'new', :controller => 'admin/products')) %></p>
<p><%=link_to('Update product database', url_for(:action => 'index', :controller => 'admin/parser')) %></p>
<%form_tag(admin_products_path, :method => :get) do %>
<table>
	<tr>
		<td width="10%">Titel:</td>
		<td width="10%">Categorie:</td>
	</tr>
	<tr>
		<td width="10%"><%= text_field_tag :title, @title%></td>
		<td width="10%"><%= text_field_tag :category, @category%></td>
	</tr>
	<tr>
		<td width="10%">Prijs klasse:</td>
	</tr>
	<tr>
		<td width="10%"><%= text_field_tag :price_from, @price_from, :size => 6%>t/m<%= text_field_tag :price_to, @price_to, :size => 6%></td>
		<td width="10%"><%=submit_tag 'Zoek'%></td>
	</tr>
</table>
<%end%>
<table>
	<%if(@products.size>0)%>
		
		<tr>
			<%sort = @params[:sort]%>
			<%sort_on = @params[:sort_on]%>
			<th align="left">Titel:<%= link_to image_tag("asc.gif"), admin_products_path(@params, @params[:sort] = 'ASC', @params[:sort_on] = 'products.name')%><%= link_to image_tag("desc.gif"), admin_products_path(@params, @params[:sort] = 'DESC', @params[:sort_on] = 'products.name')%></td>
			<th align="left">Prijs:<%= link_to image_tag("asc.gif"), admin_products_path(@params, @params[:sort] = 'ASC', @params[:sort_on] = 'products.price')%><%= link_to image_tag("desc.gif"), admin_products_path(@params, @params[:sort] = 'DESC', @params[:sort_on] = 'products.price')%></td>
			<th align="left">Voorraad:<%= link_to image_tag("asc.gif"), admin_products_path(@params, @params[:sort] = 'ASC', @params[:sort_on] = 'products.stock')%><%= link_to image_tag("desc.gif"), admin_products_path(@params, @params[:sort] = 'DESC', @params[:sort_on] = 'products.stock')%></td>
			<th></td>
			<%@params[:sort] = sort%>
			<%@params[:sort_on] = sort_on%>
		</tr>
	<%end%>
		<%@products.each do |product|%>
			<%=render :partial => 'product_admin', :locals => {:product => product}%>
		<%end%>
</table>
<p>
<% if(@indices[0] > -1)%>
	<%= link_to 'vorige', admin_products_path(@params, @params[:page] = @indices[0])%>
<%end%>
<% if(@indices[1] != nil)%>
	<%= link_to 'volgende', admin_products_path(@params, @params[:page] = @indices[1])%>
<%end%>
</p>